package com.whpost.api.controller.wx;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.whpost.api.controller.BaseController;
import com.whpost.api.utils.ApiUtils;
import com.whpost.service.entity.tools.ResultInfo;
import com.whpost.service.service.t.TCzyServices;
import com.whpost.service.tools.ToolBean;
import com.whpost.service.tools.Url;
import com.whpost.service.wx.service.BaomingServices;
import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wx/bm")
public class BaomingController {

    @Resource
    private BaomingServices baomingServices;

    @RequestMapping(value ="/info")
    public ResultInfo info(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return baomingServices.info(loginId,map);
    }

    @RequestMapping(value ="/save")
    public ResultInfo save(@RequestParam(value = "wj", required = false) List<MultipartFile> wj,@RequestParam(value = "data", required = false) String data){
        String loginId = ApiUtils.getLoginId();
        System.out.println("data:"+data);
        System.out.println("List<MultipartFile>:"+wj);
        return baomingServices.save(loginId,wj,data);
    }

    @RequestMapping(value ="/query")
    public ResultInfo query(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return baomingServices.query(loginId,map);
    }

    @RequestMapping(value ="/del")
    public ResultInfo del(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return baomingServices.del(loginId,map);
    }

    @RequestMapping(value ="/index")
    public ResultInfo index(@RequestBody Map<String, Object> map){
        String loginId = ApiUtils.getLoginId();
        return baomingServices.index(loginId,map);
    }

    //推荐背景图片
    @RequestMapping(value = "/tj_bjtp",produces = MediaType.IMAGE_JPEG_VALUE)
    @ResponseBody
    public byte[] tjBjtp(String id){
        return baomingServices.getTjbj(id);
    }
}
